<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="/resource/js/jquery-3.6.0.js"></script>
<script type="text/javascript">


 function upload(){
	 
	 var formData=new FormData($("form")[0]);
	 $.ajax({
		 url:"upload",
		 type:"post",
		 data:formData,
		 processData:false,
		 contentType:false,
		 success:function(obj){
			 $("img").prop("src",obj);
			 $("[name='pic']").val(obj);
		 }
	 })
	 
	 
 }

</script>
</head>
<body>
<form:form action="add" method="post" modelAttribute="a">
文章标题:<form:input path="title"/><br><br>
文章内容:<form:input path="content"/><br><br>
文章摘要:<form:input path="zhaiyao"/><br><br>
图片:<input type="file" name="file" onchange="upload()">
<img alt="" src="" height="50px" width="50px">
<input type="text" name="pic"><br><br>
<form:button>提交</form:button>
</form:form>
</body>
</html>